
 
 S l o t M o t o r 1   =   1 
 
 S l o t M o t o r 2   =   3 
 
 S l o t S w i t c h S t a r t 1   =   1 1 
 
 S l o t S w i t c h E n d 1   =   7 
 
 S l o t S w i t c h S t a r t 2   =   1 2 
 
 S l o t S w i t c h E n d 2   =   8 
 
 
 
 K e y J o g _ S p e e d   =   2 0 
 
 
 
 M o t 1 M i n   =   0 
 
 M o t 1 M a x   =   6 5 0 
 
 M o t 2 M i n   =   0 
 
 M o t 2 M a x   =   6 5 0 
 
 
 
 B u t t o n   1   T e x t   H O M E   M O T O R S 
 
 B u t t o n   2   T e x t   T e s t 1 
 
 B u t t o n   3   T e x t   T e s t 2 
 
 B u t t o n   5   T e x t   L o o p 
 
 
 
 K e y   R i g h t 	 	 G o s u b   E x e c K e y s   
 
 K e y   L e f t   	 	 G o s u b   E x e c K e y s 
 
 K e y   U p   	 	 	 G o s u b   E x e c K e y s 
 
 K e y   D o w n   	 	 G o s u b   E x e c K e y s 
 
 
 
 ' G o s u b   " H O M E   M O T O R S " 
 
 
 
 ' L o a d   V a r s 
 
 ' P o s 1   =   v 1 
 
 ' P o s 2   =   v 2 
 
 ' G o s u b   P r i n t V a l u e s 
 
 
 
 S t o p 
 
 
 
 ' L a b e l   E v e n t S t o p 
 
 ' 	 v 1   =   P o s 1 
 
 ' 	 v 2   =   P o s 2 
 
 ' 	 S a v e   V a r s 
 
 ' E n d 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '     V A R S 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 V a r i a b l e   N u m e r i c   S l o t M o t o r 1 
 
 V a r i a b l e   N u m e r i c   S l o t M o t o r 2 
 
 V a r i a b l e   N u m e r i c   S l o t S w i t c h S t a r t 1 
 
 V a r i a b l e   N u m e r i c   S l o t S w i t c h E n d 1 
 
 V a r i a b l e   N u m e r i c   S l o t S w i t c h S t a r t 2 
 
 V a r i a b l e   N u m e r i c   S l o t S w i t c h E n d 2 
 
 
 
 V a r i a b l e   N u m e r i c   M o t 1 M i n 
 
 V a r i a b l e   N u m e r i c   M o t 1 M a x 
 
 V a r i a b l e   N u m e r i c   M o t 2 M i n 
 
 V a r i a b l e   N u m e r i c   M o t 2 M a x 
 
 
 
 ' V a r i a b l e   N u m e r i c   P o s 1 
 
 ' V a r i a b l e   N u m e r i c   P o s 2 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '   E N A B L E / D I S A B L E   B U T T O N S 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   E n a b l e A l l B u t t o n s 
 
 	 F o r   v 1   =   1   T o   3 2 
 
 	 	 B u t t o n   v 1   E n a b l e d 
 
 	 N e x t 
 
 R e t u r n 
 
 
 
 L a b e l   D i s a b l e A l l B u t t o n s 
 
 	 F o r   v 1   =   1   T o   3 2 
 
 	 	 B u t t o n   v 1   D i s a b l e d 
 
 	 N e x t 
 
 R e t u r n 
 
 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '     L O O P   T E S T 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 ' 
 
 L a b e l   T e s t 1 
 
 	 
 
 R e t u r n 
 
 
 
 L a b e l   T e s t 2 
 
 	 
 
 R e t u r n 
 
 
 
 L a b e l   L o o p 
 
 	 
 
 	 M o v e S l o w _ D e s t 1   =   6 0 0 
 
 	 M o v e S l o w _ D e s t 2   =   1 0 
 
 	 M o v e S l o w _ S p e e d   =   1 0 0 
 
 	 G o s u b   M o v e S l o w 
 
 	 
 
 	 M o v e S l o w _ D e s t 1   =   6 0 0 
 
 	 M o v e S l o w _ D e s t 2   =   6 0 0 
 
 	 M o v e S l o w _ S p e e d   =   1 0 0 
 
 	 G o s u b   M o v e S l o w 
 
 	 
 
 	 M o v e S l o w _ D e s t 1   =   1 0 0 
 
 	 M o v e S l o w _ D e s t 2   =   6 0 0 
 
 	 M o v e S l o w _ S p e e d   =   1 0 0 
 
 	 G o s u b   M o v e S l o w 
 
 	 
 
 G o t o   L o o p 
 
 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '     M O V E   S L O W   X Y 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 V a r i a b l e   N u m e r i c   M o v e S l o w _ D e s t 1   	 '   d e s t i n a t i o n   i n   m m 
 
 V a r i a b l e   N u m e r i c   M o v e S l o w _ D e s t 2   	 '   d e s t i n a t i o n   i n   m m 
 
 V a r i a b l e   N u m e r i c   M o v e S l o w _ S p e e d   	 '   s p e e d   i n   m m / s e c 
 
 
 
 V a r i a b l e   N u m e r i c   M S V 1 
 
 V a r i a b l e   N u m e r i c   M S V 2 
 
 V a r i a b l e   N u m e r i c   M S V 3 
 
 V a r i a b l e   N u m e r i c   M S V 4 
 
 
 
 L a b e l   M o v e S l o w 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   t e s t   f o r   o u t   o f   l i m i t 
 
 	 S l o t ( S l o t M o t o r 1 )   =   L i m i t ( S l o t ( S l o t M o t o r 1 ) ,   M o t 1 M i n ,   M o t 1 M a x ) 
 
 	 S l o t ( S l o t M o t o r 2 )   =   L i m i t ( S l o t ( S l o t M o t o r 2 ) ,   M o t 2 M i n ,   M o t 2 M a x ) 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   t e s t   f o r   v e r y   l o w   s p e e d 
 
 	 I f   M o v e S l o w _ S p e e d   <   0 . 1 
 
 	 	 M o v e S l o w _ S p e e d   =   1 
 
 	 E n d I f 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   c a l c   t h e   m o v e m e n t   i n   m m 
 
 	 M S V 1   =   M o v e S l o w _ D e s t 1   -   S l o t ( S l o t M o t o r 1 ) 
 
 	 M S V 2   =   M o v e S l o w _ D e s t 2   -   S l o t ( S l o t M o t o r 2 ) 
 
 	 M S V 3   =   M S V 1   *   M S V 1 
 
 	 M S V 3   =   M S V 3   +   M S V 2   *   M S V 2 
 
 	 M S V 3   =   S q r t ( M S V 3 ) 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   c a l c   t h e   l o o p s   c o u n t 
 
 	 M S V 4   =   M S V 3   /   0 . 0 1   ' < < <   l o o p   t i m e 
 
 	 M S V 4   =   I n t ( M S V 4   /   M o v e S l o w _ S p e e d ) 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   t o o   m u c h   s p e e d   ? 
 
 	 I f   M S V 4   =   0 
 
 	 	 S l o t ( S l o t M o t o r 1 )   =   L i m i t ( M o v e S l o w _ D e s t 1 ,   M o t 1 M i n ,   M o t 1 M a x ) 
 
 	 	 S l o t ( S l o t M o t o r 2 )   =   L i m i t ( M o v e S l o w _ D e s t 2 ,   M o t 2 M i n ,   M o t 2 M a x ) 
 
 	 	 R e t u r n 
 
 	 E n d I f 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   p r e p a r e   t h e   i n c r e m e n t s 
 
 	 M S V 1   =   ( M o v e S l o w _ D e s t 1   -   S l o t ( S l o t M o t o r 1 ) )   /   M S V 4 
 
 	 M S V 2   =   ( M o v e S l o w _ D e s t 2   -   S l o t ( S l o t M o t o r 2 ) )   /   M S V 4 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   l o o p   f o r   v 4   t i m e s 
 
 	 F o r   M S V 3   =   1   T o   M S V 4 
 
 	 	 '   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   i n c r e m e n t ,   m o v e   a n d   w a i t 
 
 	 	 S l o t ( S l o t M o t o r 1 )   =   L i m i t ( S l o t ( S l o t M o t o r 1 )   +   M S V 1 ,   M o t 1 M i n ,   M o t 1 M a x ) 
 
 	 	 S l o t ( S l o t M o t o r 2 )   =   L i m i t ( S l o t ( S l o t M o t o r 2 )   +   M S V 2 ,   M o t 2 M i n ,   M o t 2 M a x ) 
 
 	 	 W a i t   S e c o n d s   0 . 0 1   ' < < <   l o o p   t i m e 
 
 	 	 G o s u b   P r i n t V a l u e s 
 
 	 N e x t 
 
 	 ' G o s u b   W a i t A l l M o t o r s A n d R e c o v e r y 
 
 	 G o s u b   W a i t A l l M o t o r s 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '     H O M E   M O T O R S 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   H O M E   M O T O R S 
 
 	 S l o t M o t o r   =   S l o t M o t o r 1 
 
 	 S l o t S e n s o r   =   S l o t S w i t c h S t a r t 1 
 
 	 S p e e d S e a r c h   =   - 0 . 2 5           '   s e a r c h   d i r e c t i o n   a n d   s p e e d 
 
 	 S p e e d R e t u r n   =   + 0 . 0 5           '   r e t u r n   d i r e c t i o n   a n d   s p e e d 
 
 	 D e c l a r e d S w i t c h P o s   =   0 
 
 	 I n i t i a l P o s i t i o n   =   5           '   r e l a t i v e   t o   D e c l a r e d Z e r o 
 
 	 G o s u b   H o m e M o t o r 
 
 	 
 
 	 S l o t M o t o r   =   S l o t M o t o r 2 
 
 	 S l o t S e n s o r   =   S l o t S w i t c h S t a r t 2 
 
 	 S p e e d S e a r c h   =   - 0 . 2 5         '   s e a r c h   d i r e c t i o n   a n d   s p e e d 
 
 	 S p e e d R e t u r n   =   + 0 . 0 5         '   r e t u r n d i r e c t i o n   a n d   s p e e d 
 
 	 D e c l a r e d S w i t c h P o s   =   0 
 
 	 I n i t i a l P o s i t i o n   =   5         '   r e l a t i v e   t o   D e c l a r e d Z e r o 
 
 	 G o s u b   H o m e M o t o r 
 
 	 
 
 	 G o s u b   P r i n t V a l u e s 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '     H o m e   t h e   M o t o r ( S l o t M o t o r )   t o   t h e   S e n s o r ( S l o t S e n s o r ) 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 V a r i a b l e   N u m e r i c   S l o t M o t o r 
 
 V a r i a b l e   N u m e r i c   S l o t S e n s o r 
 
 V a r i a b l e   N u m e r i c   S p e e d S e a r c h 
 
 V a r i a b l e   N u m e r i c   S p e e d R e t u r n 
 
 V a r i a b l e   N u m e r i c   D e c l a r e d S w i t c h P o s 
 
 V a r i a b l e   N u m e r i c   I n i t i a l P o s i t i o n 
 
 
 
 L a b e l   H o m e M o t o r 
 
 	 G o s u b   D i s a b l e A l l B u t t o n s 
 
 	 B u t t o n   1 5   E n a b l e d 
 
 	 '   - - - - - - - - - - - - - - - - - - - - - - - - -   d e t a c h   i f   s e n s o r   i s   a c t i v e 
 
 	 I f   S l o t ( S l o t S e n s o r )   >   5 0 0   O r   K e y ( " C T R L " ) 
 
 	 	 S l o t ( S l o t M o t o r )   =   S l o t ( S l o t M o t o r )   +   S p e e d R e t u r n 
 
 	 E n d I f 
 
         '   - - - - - - - - - - - - - - - - - - - - - - - - -   s e a r c h   t h e   s e n s o r 
 
 L a b e l   S e a r c h H o m e 
 
 	 S l o t ( S l o t M o t o r )   =   S l o t ( S l o t M o t o r )   +   S p e e d S e a r c h 
 
 	 W a i t   S e c o n d s   0 . 0 0 1 
 
 	 I f   S l o t ( S l o t S e n s o r )   >   5 0 0   O r   K e y ( " C T R L " ) 
 
 	 	 S l o t ( S l o t M o t o r )   =   R e s e t 
 
 	 	 W a i t   S e c o n d s   0 . 1 
 
 	 	 S l o t ( S l o t M o t o r )   =   0 
 
 	 	 W a i t   S e c o n d s   0 . 1 
 
 	 	 G o t o   D e t a c h S e n s o r 
 
 	 E n d I f 
 
 G o t o   S e a r c h H o m e 
 
         '   - - - - - - - - - - - - - - - - - - - - - - - - -   d e t a c h   f r o m   t h e   s e n s o r 
 
 L a b e l   D e t a c h S e n s o r 
 
 	 S l o t ( S l o t M o t o r )   =   S l o t ( S l o t M o t o r )   +   S p e e d R e t u r n 
 
 	 W a i t   S e c o n d s   0 . 0 0 1 
 
 	 I f   S l o t   ( S l o t S e n s o r )   <   5 0 0 
 
 	 	 S l o t ( S l o t M o t o r )   =   R e s e t 
 
 	 	 W a i t   S e c o n d s   0 . 1 
 
 	 	 S l o t ( S l o t M o t o r )   =   D e c l a r e d S w i t c h P o s 
 
 	 	 W a i t   S e c o n d s   0 . 1 
 
 	 	 G o t o   S e t F i n a l V a l u e s 
 
 	 E n d I f 
 
 G o t o   D e t a c h S e n s o r 
 
         '   - - - - - - - - - - - - - - - - - - - - - - - - -   r e s e t   a n d   m o v e   t o   I n i t i a l P o s 
 
 L a b e l   S e t F i n a l V a l u e s 
 
 	 S l o t ( S l o t M o t o r )   =   I n i t i a l P o s i t i o n 
 
 	 G o s u b   W a i t M o t o r 
 
 	 G o s u b   E n a b l e A l l B u t t o n s 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '       W a i t   u n t i l   t h e   m o t o r ( S l o t M o t o r )   i s   s t o p p e d 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   W a i t M o t o r 
 
 	 W a i t   S e c o n d s   0 . 1 
 
 	 V a r i a b l e   N u m e r i c   W a i t M o t 1 
 
 	 F o r   W a i t M o t 1   =   1   T o   9 e 9 9 
 
 	 	 I f   A b s ( S l o t ( S l o t M o t o r   +   1 ) )   <   0 . 0 1 
 
 	 	 	 E x i t 
 
 	 	 E n d I f 
 
 	 	 W a i t   S e c o n d s   0 . 0 0 5 
 
 	 N e x t 
 
 R e t u r n 
 
 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '       W a i t   u n t i l   A l l - M o t o r s   a r e   s t o p p e d 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   W a i t A l l M o t o r s 
 
 	 W a i t   S e c o n d s   0 . 1   '   < < <   e n s u r e s   t h a t   m o t o r s   a r e   r e a l l y   s t a r t e d 
 
 	 V a r i a b l e   N u m e r i c   W a i t M o t 2 
 
 	 F o r   W a i t M o t 2   =   1   T o   9 e 9 9 
 
 	 	 I f   A b s ( S l o t ( S l o t M o t o r 1   +   1 ) )   <   0 . 0 1   A n d   A b s ( S l o t ( S l o t M o t o r 2   +   1 ) )   <   0 . 0 1 
 
 	 	 	 E x i t 
 
 	 	 E n d I f 
 
 	 	 W a i t   S e c o n d s   0 . 0 0 5 
 
 	 N e x t 
 
 R e t u r n 
 
 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '     J O G   w i t h   k e y b o a r d 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   E x e c K e y s 
 
 	 V a r i a b l e   N u m e r i c   K e y J o g _ S p e e d 
 
 	 V a r i a b l e   N u m e r i c   J o g S p e e d 
 
 	 J o g S p e e d   =   K e y J o g _ S p e e d   /   1 0 0 
 
 	 S e l e c t   T r u e 
 
 	 	 C a s e   K e y ( " S H I F T " ) 
 
 	 	 	 J o g S p e e d   =   J o g S p e e d   *   1 0 0 
 
 	 	 C a s e   K e y ( " C T R L " ) 
 
 	 	 	 J o g S p e e d   =   J o g S p e e d   *   1 0 
 
 	 	 C a s e   K e y ( " A L T " ) 
 
 	 	 	 J o g S p e e d   =   J o g S p e e d   *   0 . 1 
 
 	 E n d S e l e c t 
 
 	 ' 
 
 	 I f   K e y ( " R i g h t " ) 
 
 	 	 S l o t   S l o t M o t o r 1   =   L i m i t ( S l o t ( S l o t M o t o r 1 )   +   J o g S p e e d ,   M o t 1 M i n ,   M o t 1 M a x ) 
 
 	 E n d I f 
 
 	 I f   K e y ( " L e f t " ) 
 
 	 	 S l o t   S l o t M o t o r 1   =   L i m i t ( S l o t ( S l o t M o t o r 1 )   -   J o g S p e e d ,   M o t 1 M i n ,   M o t 1 M a x ) 
 
 	 E n d I f 
 
 	 ' 
 
 	 I f   K e y ( " U p " ) 
 
 	 	 S l o t   S l o t M o t o r 2   =   L i m i t ( S l o t ( S l o t M o t o r 2 )   +   J o g S p e e d ,   M o t 2 M i n ,   M o t 2 M a x ) 
 
 	 E n d I f 
 
 	 I f   K e y ( " D o w n " ) 
 
 	 	 S l o t   S l o t M o t o r 2   =   L i m i t ( S l o t ( S l o t M o t o r 2 )   -   J o g S p e e d ,   M o t 2 M i n ,   M o t 2 M a x ) 
 
 	 E n d I f 
 
 	 ' 
 
 	 G o s u b   P r i n t V a l u e s 
 
 R e t u r n 
 
 
 
 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '     P R I N T   V A L U E S 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   P r i n t V a l u e s 
 
 	 s 1   =               " X = "   +   F o r m a t ( S l o t ( S l o t M o t o r 1 ) ,   " 0 . 0 0 0 " ) 
 
 	 s 1   =   s 1   +   "   Y = "   +   F o r m a t ( S l o t ( S l o t M o t o r 2 ) ,   " 0 . 0 0 0 " ) 
 
 	 P r i n t   C R L F   +   s 1 
 
 R e t u r n 
 
 
 
 ' W A T C H   S p e e d 
 
 ' W A T C H   W a i t   S e c o n d s   2 
 
 ' W A T C H   W a i t   S e c o n d s   2 
 
 ' W A T C H   W a i t   S e c o n d s   2 
 
 ' W A T C H   W a i t   S e c o n d s   2 
 
 ' W A T C H   W a i t   S e c o n d s   2 
 
 ' E X E C   S l o t ( 2 )   =   0 
 
 